package net.lainiao.morethread.Chapter3.demo4;

import java.util.Random;

/**
 * Created by Administrator on 2017/3/1.
 */
public class MatrixMock {
    private int data[][];

    public MatrixMock(int size, int length, int number) {
        int counter = 0;
        data = new int[size][length];
        Random random = new Random();
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < length; j++) {
                int tem = random.nextInt(10);
                data[i][j] = tem;
                if (tem == number) {
                    counter++;
                }
            }
        }
        System.out.println("矩阵中有值为" + number + "的数字有:" + counter + "个");
    }

    public int[] getRow(int row){
        if(row>=0&&row<data.length){
            return data[row];
        }
        return null;
    }


}
